package com.sui.bigdata.rtcadmin.service.impl;


import com.sui.bigdata.rtcadmin.dto.JobConfigDto;
import com.sui.bigdata.rtcadmin.exception.ActionNotSupportException;
import com.sui.bigdata.rtcadmin.service.JobOperationService;
import com.sui.bigdata.rtcadmin.constant.JobConstant;
import com.sui.bigdata.rtcadmin.util.JobActionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;


/**
 * @author YongChen
 * @date 2019/11/14 13:56
 * @description
 * @email yong_chen@sui.com
 */
@Service
public class JobOperationServiceImpl implements JobOperationService {

    @Autowired
    private JobActionUtils jobActionUtils;

    @Override
    public void action(String action, JobConfigDto jobConfigDto) throws Exception  {

        switch (action){
            case JobConstant.SUBMIT:
                jobActionUtils.submit(jobConfigDto);
                break;
            case JobConstant.RESTART:
                jobActionUtils.restart(jobConfigDto);
                break;
            case JobConstant.STOP:
                jobActionUtils.stop(jobConfigDto);
                break;
            case JobConstant.RESTARTALL:
                jobActionUtils.restartAll(jobConfigDto);
                break;
            default:
                throw new ActionNotSupportException();
        }
    }
}
